import pygame
import sys
from pygame.locals import *
from collections import deque
import random

from graph import Graph
from snake2 import Snake
from food import Food
if __name__ == '__main__':
    
    pygame.init()
    WIDTH, HEIGHT = (1400,1000)
    SCREEN_SIZE = (WIDTH, HEIGHT)
    screen = pygame.display.set_mode(SCREEN_SIZE)
    pygame.display.set_caption("snake")
    clock = pygame.time.Clock()
    size = 20
    graph = Graph(SCREEN_SIZE, size)
    food = Food(graph,(5,5,5))
    snake = Snake(graph,(0,0),food,(100,100,100))

    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    pygame.quit()
                    sys.exit()
        
        background_color = (5,125,150)
        screen.fill(background_color)
        key = pygame.key.get_pressed()
        snake.key_event(key)

        snake.move()
        snake.display(screen)
        food.display(screen)
        pygame.display.update()
        pygame.display.flip()
        clock.tick(10)

